# -*- coding: utf-8 -*-

"""
Module implementing serialCom.
"""

import serial as Pyserial
import serial.tools.list_ports




class RSerial(Pyserial.Serial):
    def __init__(self):
        # print locals()
        super(Pyserial.Serial, self).__init__()
        pass

    def getAvailablePortName(self):
        self.ports_list = list(serial.tools.list_ports.comports())
        name_list = []
        for i in self.ports_list:
            name_list.append(i[0])  # 在控制台下测试发现返回的值是以gbk编码，汉字的编码可以到网站http://bm.kdd.cc/查询
        return name_list


if __name__ == '__main__':
    xSerial = RSerial()
    print(xSerial.getAvailablePortName())